﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using Moq;

namespace MvcWiki.Test.Repository.FileSystem.WikiPageFileSystemRepository
{
    public class DeleteWikiPageFacts
    {
        [Fact]
        public void Call()
        {
            var wikiPage = new MvcWiki.Model.WikiPage();

            var repositoryFactory = new Mock<MvcWiki.Repository.IWikiRepositoryFactory>();
            var unitOfWork = new Mock<MvcWiki.Repository.IUnitOfWork>();
            var fileSystem = new Mock<MvcWiki.Repository.FileSystem.IFileSystemWrapper>();

            var wikiPageRepository = new MvcWiki.Repository.FileSystem.WikiPageFileSystemRepository(repositoryFactory.Object, unitOfWork.Object, "c:\\path", fileSystem.Object);

            wikiPageRepository.DeleteWikiPage(wikiPage);
        }

        [Fact]
        public void Calls_IUnitOfWork_Deleted()
        {
            var wikiPage = new MvcWiki.Model.WikiPage();

            var repositoryFactory = new Mock<MvcWiki.Repository.IWikiRepositoryFactory>();
            var unitOfWork = new Mock<MvcWiki.Repository.IUnitOfWork>();
            var fileSystem = new Mock<MvcWiki.Repository.FileSystem.IFileSystemWrapper>();

            var wikiPageRepository = new MvcWiki.Repository.FileSystem.WikiPageFileSystemRepository(repositoryFactory.Object, unitOfWork.Object, "c:\\path", fileSystem.Object);

            unitOfWork.Setup(x => x.Deleted(wikiPage, wikiPageRepository));

            wikiPageRepository.DeleteWikiPage(wikiPage);

            unitOfWork.VerifyAll();
        }
    }
}
